import {
  MenuParams,
  MenuListGetResultModel,
  AccessListGetResultModel,
  AccessParams,
  PageAutAccessGetResultModel,
  INotificationGetResultModel,
} from './model/systemModel';
import { defHttp } from '@/utils/http/axios';

enum Api {
  MENU_LIST = '/api/admin/v1/admin-menu/list',
  MENU_ADD = '/api/admin/v1/admin-menu/add',
  MENU_EDL = '/api/admin/v1/admin-menu/del',
  MENU_EDIT = '/api/admin/v1/admin-menu/edit',
  ACCESS_LIST = '/api/admin/v1/admin-access/list',
  ADD_ACCESS_LIST = '/api/admin/v1/admin-access/add',
  EDIT_ACCESS_LIST = '/api/admin/v1/admin-access/edit',
  DEL_ACCESS_LIST = '/api/admin/v1/admin-access/del',
  SYSTEM_VERSION = '/api/admin/v1/system_version',
  Accounts_Auth_Access = '/api/admin/v1/admin-access/list',
  TipsList = '/api/admin/v1/tips/list',
  TipsRead = '/api/admin/v1/tips/read',
}

export const getMenuList = (params?: MenuParams) =>
  defHttp.get<MenuListGetResultModel>({ url: Api.MENU_LIST, params });

export const addMenuItem = (params: MenuParams) => defHttp.post({ url: Api.MENU_ADD, params });

export const editMenuItem = (params: MenuParams) => defHttp.put({ url: Api.MENU_EDIT, params });

export const delMenuItem = (params: { ids: string }) =>
  defHttp.delete({ url: Api.MENU_EDL, params });

export const getAccessList = (params: { menu_id: string }) =>
  defHttp.get<AccessListGetResultModel>({ url: Api.ACCESS_LIST, params });

export const addAccessItem = (params: AccessParams) =>
  defHttp.post({ url: Api.ADD_ACCESS_LIST, params });

export const editAccessItem = (params: AccessParams) =>
  defHttp.put({ url: Api.EDIT_ACCESS_LIST, params });

export const delAccessItem = (params: { ids: string }) =>
  defHttp.delete({ url: Api.DEL_ACCESS_LIST, params });

export const getPageAuthAccessList = (params: { menu_id: number }) =>
  defHttp.get<PageAutAccessGetResultModel>({ url: Api.Accounts_Auth_Access, params });

export const getSystemVersion = () => defHttp.get({ url: Api.SYSTEM_VERSION });

/**
 * 获取提示列表
 */
export const apiTipsList = () => defHttp.post<INotificationGetResultModel>({ url: Api.TipsList });

/**
 * 标记已读
 * @param params
 */
export const apiTipsRead = (params: { tips_id: number }) =>
  defHttp.post({ url: Api.TipsRead, params });
